package com.yc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.entity.Cart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * InnoDB free: 5120 kB; (`pid`) REFER `test/product`(`pid`) ON DELETE NO ACTION Mapper 接口
 * </p>
 *
 * @author ly
 * @since 2022-05-08
 */
public interface CartMapper extends BaseMapper<Cart> {
    @Update("update cart set count=count+1 where"+
    " uid=#{uid} and pid=#{pid}")
    int updateCount(Cart cart);

    @Select("select * from cart where uid=#{uid}")
    @Results({
            @Result(column = "id",property = "id",id=true),
            @Result(column = "pid",property = "product",one = @One(select = "com.baomidou.mybatisplus.core.mapper.Product.selectById") )
    })
    List<Cart> selectByUid(int uid);
}
